package com.eugene.shiftscalendar;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;

import java.util.Calendar;

/**
 * Created by Eugene on 02.04.14.
 */
public abstract class BasePainter {
    protected int dayRow;
    protected int dayCol;
    protected WidgetSizes _sizes;
    protected Context _context;
    protected DateType _dateType;

    public void setDayPos(int row, int col){
        dayRow = row;
        dayCol = col;
    }

    public BasePainter(WidgetSizes sizes)
    {
        _sizes = sizes;
        _dateType = new DateType();
    }

    public Bitmap getBitmap(WidgetSizes.WidgetType type, Calendar cal, Context context)
    {
        _context = context;

        Point sizes = getSize(type);
        int szX = sizes.x;
        int szY = sizes.y;
        Bitmap btmText = Bitmap.createBitmap(szX, szY, MainWindow.EMULATOR ? Bitmap.Config.ARGB_4444 : Bitmap.Config.ARGB_8888);
        Canvas cnvText = new Canvas(btmText);

        switch(type){
            case Title:
                paintTitle(cnvText, cal);
                break;
            case Prev:
                paintPrev(cnvText);
                break;
            case Next:
                paintNext(cnvText);
                break;
            case Settings:
                paintSettings(cnvText);
                break;
            case Weeks:
                paintWeeks(cnvText);
                break;
            case LeftSide:
                paintLeftSide(cnvText);
                break;
            case RightSide:
                paintRightSide(cnvText);
                break;
            case Footer:
                paintFooter(cnvText);
                break;
            case Day:
                paintDay(cnvText, cal);
                break;
            case Upper:
                paintUpper(cnvText);
                break;
        }
        return btmText;
    }

    abstract Point getSize(WidgetSizes.WidgetType type);
    abstract void paintTitle(Canvas cnv, Calendar cal);
    abstract void paintPrev(Canvas cnv);
    abstract void paintNext(Canvas cnv);
    abstract void paintSettings(Canvas cnv);
    abstract void paintWeeks(Canvas cnv);
    abstract void paintFooter(Canvas cnv);
    abstract void paintDay(Canvas cnv, Calendar cal);
    abstract void paintLeftSide(Canvas cnv);
    abstract void paintRightSide(Canvas cnv);
    abstract void paintUpper(Canvas cnv);
    abstract int mainLayout();
}
